<?php
/** [广告位置控制器]
 * @Author: 976123967@qq.com
 * @Date:   2015-01-16 11:33:22
 * @Last Modified by:   Administrator
 * @Last Modified time: 2015-01-17 17:44:04
 */
class PositionAction extends PublicAction{

	public $logic;

	/**
	 * [_initialize 初始化]
	 * @return [type] [description]
	 */
	public function _initialize()
	{
		parent::_initialize();

		$this->logic  = D('Position','Logic');

	}


	/**
	 * [index 所有广告位置列表]
	 * @return [type] [description]
	 */
	public function index()
	{
		$data = $this->logic->get_all();
		$this->assign('data',$data);
		$this->display();
	}

	/**
	 * [add 添加]
	 */
	public function add()
	{
		if(IS_POST)
		{
			if(!$this->logic->add_position())
				$this->error($this->logic->getError());
			$this->success('广告位置添加成功',U('Position/index'));
			die;
		}
		$this->display();
	}


	/**
	 * [edit 编辑]
	 * @return [type] [description]
	 */
	public function edit()
	{
		if(IS_POST)
		{
			if(!$this->logic->edit_position())
				$this->error($this->logic->getError());
			$this->success('广告位置编辑成功',U('Position/index'));
			die;
		}


		$field = $this->logic->find_one();
		if(!$field)
			$this->error('链接错误');
		$this->assign('field',$field);
		$this->display();
	}

	/**
	 * [update_cache 更新缓存]
	 * @return [type] [description]
	 */
	public function update_cache()
	{
		$this->logic->update_cache();
		$this->success('缓存更新成功',U('Position/index'));
	}


	/**
	 * [del 删除]
	 * @return [type] [description]
	 */
	public function del()
	{
		if(!$this->logic->del_position())
			$this->error($this->logic->getError());
		$this->success('广告外置删除成功',U('Position/index'));
	}
}